<template>
  <div class="box">
    <!-- {{data}} -->
    <h1>{{ data.name }}</h1>
    <div v-for="item in data.goodsList" :key="item.id" @click="goAbout(item.id)">
      <img v-lazy="item.list_pic_url" alt="" />
      <p>
        {{ item.name }}
      </p>
      <span>
        {{ item.retail_price | RMBformat }}
      </span>
    </div>
  </div>
</template>

<script>
import {  mapMutations } from "vuex";
export default {
  name: "CateGory",
  props: ["data"],
  data() {
    return {
      arr: [],
      name: this.data.name,
    };
  },
  methods:{
    ...mapMutations(["chanGe"]),
    goAbout(value){
      this.chanGe()
      this.$router.push({name:"About",params:{id:value,onoff:true}})
      console.log(value);
    }
  }
  // mounted(){
  //     console.log("重用组件",this.data);
  //     this.name=this.data.name
  //     this.arr=this.data.goodsList
  //     console.log(this.arr);
  // }
};
</script>

<style scoped lang="less">
.box {
  // height: 500px;
  overflow: hidden;
  position: relative;
  margin-top: 55px;
  // background: rgb(193, 203, 183);
  h1 {
    text-align: center;
    font-size: 20px;
    width: 100%;
  }
  div {
    width: 50%;
    height: 150px;
    // background: chocolate;
    float: left;
    margin: 10px 0px;
    img {
      width: 80%;
      height: 80%;
      margin: auto;
      display: block;
    }
    p {
      text-align: center;
      font-size: 15px;
      margin-top: -10px;
    }
    span {
      display: block;
      width: 100%;
      text-align: center;
      font-size: 14px;
      margin-top: 10px;
      transform: scaleX(1.1);
      color: darkred;
    }
  }
}
</style>